package cn.calm.swing.osgi.mysql.blance.entity;

import cn.calm.swing.osgi.api.annotation.Required;
import cn.calm.swing.osgi.api.entity.AbstractModelObject;

public class HostInfo extends AbstractModelObject {
	@Required(message="请填写主机名!")
	private String hostName;
	@Required(message="请填写端口!")
	private Integer port = 3306;
	@Required(message="请填写用户名!")
	private String username;
	private String password;

	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		String oldValue = this.hostName;
		this.hostName = hostName;
		firePropertyChange("hostName", oldValue, this.hostName);
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		Integer oldValue = this.port;
		this.port = port;
		firePropertyChange("port", oldValue, this.port);
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		String oldValue = this.username;
		this.username = username;
		firePropertyChange("username", oldValue, this.username);
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		String oldValue = this.password;
		this.password = password;
		firePropertyChange("password", oldValue, this.password);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((hostName == null) ? 0 : hostName.hashCode());
		result = prime * result + ((port == null) ? 0 : port.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		HostInfo other = (HostInfo) obj;
		if (hostName == null) {
			if (other.hostName != null)
				return false;
		} else if (!hostName.equals(other.hostName))
			return false;
		if (port == null) {
			if (other.port != null)
				return false;
		} else if (!port.equals(other.port))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "主机名:" + hostName + ", 端口:" + port;
	}

}
